#ifndef __HXD1_H__
#define __HXD1_H__

// Common header file


#define COLOR_RED      "\e[31m"
#define COLOR_GREEN    "\e[32m"
#define COLOR_YELLOW   "\e[33m"
#define COLOR_BLUE     "\e[34m"
#define COLOR_MAGENTA  "\e[35m"
#define COLOR_CYAN     "\e[36m"
#define COLOR_RESET    "\e[0m"
// for error
#define BOLD_RED       "\e[1;31m"
// for info
#define BOLD_BLUE      "\e[1;34m"
// for warning
#define BOLD_MAGENTA   "\e[1;35m"

#define OPT_L1 'K'
#define OPT_L2 'T'
#define OPT_L3 'Z'
#define IR_FILE_SUFFIX ".ll"
#define ASM_FILE_SUFFIX ".s"

extern int error_code;

// The max size of a dim of an array
const long CACT_Max_array_size = 5033L;
// info prefix
const char *const HXD1_Info = BOLD_BLUE "HXD1:" COLOR_RESET " ";
// fatal error prefix
const char *const Fatal_error = BOLD_RED "fatal error:" COLOR_RESET  " ";
// normal error prefix
const char *const Normal_error = BOLD_RED "error:" COLOR_RESET " ";

struct HOptions {
	int opt_level;			// optimization level
	char debug_level;			// debug mode
	char emit_ircode;		// dump HXD1 IR code
	char dump_builtin;		// dump builtin functions
	char no_check_main;		// don't check type of `main()`
	char use_32_inst;		// use `w` size instructions (such as `addw`) as default
	char no_alloc_stack;	// don't allocate stack space for all local variables

	// optimizations for `-O1` or higher
	char opt_str_red;		// strength reduction
	char opt_dce;			// local dead code elimination
	char opt_cse;			// local common subexpr elimination
	char opt_merge_const_expr;	// merge constants
	char opt_cfg_cleanup;	// control flow graph cleanup
	char opt_gra;			// global register allocation (using graph coloring)

	const char *exe_file;	// HXD1 exe file name
	const char *out_file;	// output file name
	const char *log_file;	// Log file name
};

extern const char Optcode[];
extern HOptions opts;

#endif